iCreate STM8开发板硬件连接 |--------------------| | LED1-PD0 | | LED2-PD1 | | LED3-PD2 | | LED4-PD3 | |--------------------|
#include "led.h"#include "tim1.h"void LED_Init(void){ GPIO_Init(GPIOD,(led1|led2|led3|led4),\ GPIO_MODE_OUT_PP_HIGH_FAST);//定义LED的管脚的模式}void SetLedOFF(void){ GPIO_Write(GPIOD, 0xff);}void Led_Reverse(GPIO_Pin_TypeDef LedPins){ GPIO_WriteReverse(GPIOD, LedPins);}void LED_Display(void){ u8 PortVal; for(PortVal=0;PortVal<4;PortVal ) { GPIOD->ODR =(u8)(~(1<<PortVal)); delay_ms(100); }}
评论